home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / NTUMIN10.ARJ / FPRTOUT.C < prev    next >
C/C++ Source or Header  |  1992-03-12  |  2KB  |  68 lines

  1. /****************************************************************************
  2.  *
  3.  *      Program name : FPRTOUT.C
  4.  *
  5.  *    Written By : Eng-Huat Ong and Kian-Mong Low.
  6.  *
  7.  *      This program prints the solution cubes to the output file given
  8.  *    the solution array. It also prints the solution array to the screen.
  9.  *
  10.  * --------------------------------------------------------------------------
  11.  *    Copyright (c) 1992. All Rights Reserved. Nanyang Technological
  12.  *    University.
  13.  *
  14.  *    You are free to use, copy and distribute this software and its
  15.  *    documentation providing that:
  16.  *
  17.  *        NO FEE IS CHARGED FOR USE, COPYING OR DISTRIBUTION.
  18.  *
  19.  *        IT IS NOT MODIFIED IN ANY WAY.
  20.  *
  21.  *        THE COPYRIGHT NOTICE APPEAR IN ALL COPIES.
  22.  *
  23.  *    This program is provided "AS IS" without any warranty, expressed or
  24.  *    implied, including but not limited to fitness for any particular
  25.  *    purpose.
  26.  *
  27.  *    If you find NTUMIN fast, easy, and useful, a note or comment would be
  28.  *    appreciated. Please send to:
  29.  *
  30.  *        Boon-Tiong Tan or Othman Bin Ahmad
  31.  *        School of EEE
  32.  *        Nanyang Technological University
  33.  *        Nanyang Avenue
  34.  *        Singapore 2263
  35.  *        Republic of Singapore
  36.  *
  37.  ***************************************************************************/
  38.  
  39. #include <stdio.h>
  40.  
  41. void           fprtout(s, out)
  42. FILE           *out;
  43. unsigned char  *s;
  44.  
  45. {
  46.    unsigned short  m1, m2, m, i;
  47.    unsigned char   n, j;
  48.  
  49.  
  50.    n = *s;                       /* no. of variables */
  51.  
  52.    m1 = *(s+1);
  53.    m2 = *(s+2);
  54.    m =  m2<<8 | m1;              /* no. of cubes */
  55.  
  56.    for (i=0; i<m; i++)
  57.       {
  58.      for (j=n; j>0; j--)
  59.         {
  60.            printf("%c", *(s+3+n*i+j));
  61.            fprintf(out, "%c", *(s+3+n*i+j));
  62.         }
  63.  
  64.      printf("\n");
  65.      fprintf(out, "\n");
  66.       }
  67. }
  68.